<template>
  <view>
    <u-tabbar @change="changeTab" :value="tabIndex" :fixed="true" :placeholder="true" :safeAreaInsetBottom="true" activeColor="#09C272" inactiveColor="#7d7e80">
      <u-tabbar-item :text="item.text" :name="item.name" icon="home" v-for="item in tabList" v-bind:key="item.name" @click="tabClick(item.path)">
      </u-tabbar-item>
    </u-tabbar>
  </view>
</template>

<script>
export default {
  name: 'tab-bar',
  props: {
    tabIndex: {
       type: Number,
       default: 0
    }
  },
  data() {
    return {
       tabList: [
        {
          text: '首页',
          name: 0,
          icon: 'home',
          path: '/pages/index/index'
        },
        {
          text: '照片圈',
          name: 1,
          icon: 'photo',
          path: '/pages/photo/photo'
        },
        {
          text: '我的',
          name: 2,
          icon: 'account',
          path: '/pages/my/my'
        }
      ]
    };
  },
  methods: {
     changeTab(e) {},
     tabClick(path) {
        uni.switchTab({
           url: path
        });
     }
   }
};
</script>

<style>
/* 彻底修复TabBar样式 */
/deep/ .u-tabbar {
  box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.05) !important;
  z-index: 999 !important;
  position: fixed !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  height: auto !important;
  padding-bottom: env(safe-area-inset-bottom) !important;
}

/deep/ .u-tabbar__content {
  height: 100rpx !important;
}

/deep/ .u-tabbar__content__item-wrapper {
  height: 100rpx !important;
}

.custom-tabbar {
  display: flex;
  width: 100%;
  height: 50px;
  background-color: #ffffff;
  border-top: 1px solid #eeeeee;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
}

.tabbar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: #7d7e80;
}

.tabbar-item.active {
  color: #09C272;
}

.tabbar-icon {
  font-size: 14px;
  padding: 5px 0;
}
</style> 